<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>玩转spring boot——简单登录认证</title>
		<script src="//cdn.bootcss.com/angular.js/1.5.6/angular.min.js"></script>
		<script type="text/javascript">
			/*<![CDATA[*/
			var app = angular.module('app', []);
			app.controller('MainController', function($rootScope, $scope, $http) {
				$scope.message = '';
				$scope.account = '';
				$scope.password = '';
				//登录
				$scope.login = function() {
					$scope.message = '';
					$http({
						url: '/loginPost',
						method: 'POST',
						data: 'account=' + $scope.account + '&password=' +
							$scope.password
					}).then(function(r){
						if(!r.success) {
							$scope.message = r.message;
							return;
						}
						window.location.href = '/';
					},function(r){
						
					});
				}
			});
			/*]]>*/
		</script>
	</head>

	<body ng-app="app" ng-controller="MainController">

		<table cellspacing="1" style="background-color: #a0c6e5">
			<tr>
				<td>账号：</td>
				<td><input ng-model="account" /></td>
			</tr>
			<tr>
				<td>密码：</td>
				<td><input type="password" ng-model="password" /></td>
			</tr>
		</table>
		<input type="button" value="登录" ng-click="login()" />
		<br />
		<font color="red" ng-show="message">{{message}}</font>
		<br />
		<a href="http://www.cnblogs.com/GoodHelper/">点击访问原版博客(www.cnblogs.com/GoodHelper)</a>
	</body>

</html>